USE Wss_Content;

SELECT   DISTINCT  ScopeId
FROM       dbo.RoleAssignment
WHERE     PrincipalId IN 
(
        SELECT   DISTINCT  GroupId
        FROM       dbo.GroupMembership
        WHERE     MemberId IN (1) OR MemberId IN  
(SELECT tp_ID
FROM dbo.UserInfo
WHERE tp_Login in ('WSS-SERVER\test group2', 'WSS-SERVER\test group') 
)

) OR PrincipalId IN(1) OR PrincipalId IN  
(SELECT tp_ID
FROM dbo.UserInfo
WHERE tp_Login in ('WSS-SERVER\test group2', 'WSS-SERVER\test group') 
)